package com.cnswhy.cloud.server.merchant.controller.iot;

import com.cnswhy.cloud.server.core.entity.IotTerminalIndexConfig;
import com.cnswhy.cloud.server.core.dto.IotTerminalIndexConfigSaveDTO;
import com.cnswhy.cloud.server.core.dto.IotTerminalIndexConfigUpdateDTO;
import com.cnswhy.cloud.server.core.dto.IotTerminalIndexConfigPageDTO;
import com.cnswhy.cloud.server.core.service.IotTerminalIndexConfigService;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.cnswhy.cloud.common.core.base.controller.SuperController;
import com.cnswhy.cloud.common.core.base.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
//import com.github.zuihou.security.annotation.PreAuth;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 
 * </p>
 *
 * @author cnswhy
 * @date 2021-02-18
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/iotTerminalIndexConfig")
@Api(value = "IotTerminalIndexConfig", tags = "")
//@PreAuth(replace = "iotTerminalIndexConfig:")
public class IotTerminalIndexConfigController extends SuperController<IotTerminalIndexConfigService, Long, IotTerminalIndexConfig, IotTerminalIndexConfigPageDTO, IotTerminalIndexConfigSaveDTO, IotTerminalIndexConfigUpdateDTO> {

    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<IotTerminalIndexConfig> iotTerminalIndexConfigList = list.stream().map((map) -> {
            IotTerminalIndexConfig iotTerminalIndexConfig = IotTerminalIndexConfig.builder().build();
            return iotTerminalIndexConfig;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(iotTerminalIndexConfigList));
    }
}
